package com.reza.simpd.components.renderers
{
	import mx.containers.HBox;
	import mx.controls.Image;
	import mx.controls.Label;
	import mx.controls.Spacer;
	import mx.core.IFactory;

	public class RendererPaginatedDataGridHeader extends HBox implements IFactory
	{
		[Embed(source='../../assets/gambar/icon/pagination/arrow_up.png')]
		public var arrowUpIcon:Class;
		[Embed(source='../../assets/gambar/icon/pagination/arrow_down.png')]
		public var arrowDownIcon:Class;
		
		private var sortAsc:int;
		private var dataLabel:String;
		
		public function RendererPaginatedDataGridHeader(dL:String, sA:int) {
			super();
			horizontalScrollPolicy = "off";
			sortAsc 	= sA;
			dataLabel 	= dL;
			var label:Label = new Label();
			label.setStyle('paddingLeft', 5);
			label.text = dataLabel;
			addChild(label);
			
			if (sortAsc == 0) {
				return;
			}
			
			var spacer:Spacer = new Spacer();
			spacer.percentWidth = 100;
			addChild(spacer);
			
			var img:Image = new Image();
			img.width = 20;
			if (sortAsc == 1) {
				img.source = arrowUpIcon;
			} else {
				img.source = arrowDownIcon;
			}
			addChild(img);
		}
		
		public function newInstance():* {
			return new RendererPaginatedDataGridHeader(dataLabel, sortAsc);
		}
		
	}
}